home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / wink2 / srch / video.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-15  |  5.7 KB  |  369 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <egb.h>
  4.  
  5. extern    char    *work;
  6.  
  7.  
  8. //    47a    VC3 regs指定
  9. //    47c    VC3 regsデータ内容指定
  10. //    47d    VC3 regsデータ内容指定
  11. //    47e    VC3 regsデータ内容指定
  12. //    47f    VC3 regsデータ内容指定
  13.  
  14. //    VC3 regs
  15. //        2000    色数
  16. //        2010    ビデオ表示開始/表示状態取得/表示フィールド/指定
  17. //            47e bit2-3    表示フィールド指定
  18. //            47e bit0    表示開始
  19. //        2011    表示倍率指定
  20. //            47c        倍率指定
  21. //            47d        倍率指定
  22. //        2027    ソースビデオ映像のx1
  23. //        2028    ソースビデオ映像のx2
  24. //        2029    ソースビデオ映像のy1
  25. //        202a    ソースビデオ映像のy2
  26. //        202b    表示開始位置のx
  27. //        202c    表示開始位置のy
  28. //        202d    vramオフセット(1ラインのバイト数)
  29. //
  30.  
  31. /***********************
  32. void set_mid(int sw)
  33. {
  34.     int    i;
  35.     outp(0x47d,0x11);
  36.  
  37.     outpw(0x47a,0x2010);
  38.     i = inp(0x47c) & 0x7f;
  39.     outp(0x47c,i);
  40.     outp(0x47c,0);
  41.     outp(0x47c,0x80);
  42.     outp(0x47f,0);
  43.  
  44.     switch(sw){
  45.     case 0:
  46.         i = 4;
  47.         break;
  48.     case 1:
  49.         i = 0;
  50.         break;
  51.     case 2:
  52.         i = 8;
  53.         break;
  54.     }
  55.     outp(0x47e,i);
  56.  
  57.  
  58.     outpw(0x47a,0x2011);
  59.     outp(0x47c,0);
  60.     outp(0x47d,0x80);
  61.     outp(0x47f,9);
  62.  
  63.     outpw(0x47a,0x2020);
  64.     outpw(0x47c,0xfb7);
  65.  
  66.     outpw(0x47a,0x2022);
  67.     outpw(0x47c,0x137);
  68.  
  69.     outpw(0x47a,0x2023);
  70.     outpw(0x47c,0x7ff);
  71.  
  72.     outpw(0x47a,0x2024);
  73.     outpw(0x47c,0xff1);
  74.  
  75.     outpw(0x47a,0x2026);
  76.     outpw(0x47c,0x7ff);
  77.  
  78.     outpw(0x47a,0x2027);
  79.     outpw(0x47c,0);
  80.  
  81.     outpw(0x47a,0x2028);
  82.     outpw(0x47c,0x27f);
  83.  
  84.     outpw(0x47a,0x2029);
  85.     outpw(0x47c,0);
  86.  
  87.     outpw(0x47a,0x202a);
  88.     outpw(0x47c,0xef);
  89.  
  90.     outpw(0x47a,0x202b);
  91.     outpw(0x47c,0);
  92.  
  93.     outpw(0x47a,0x202c);
  94.     outpw(0x47c,0);
  95.  
  96.     outpw(0x47a,0x202d);
  97.     outpw(0x47c,0x200);
  98.  
  99.     outpw(0x47a,0x2010);
  100.     i = inp(0x47e) | 1;
  101.     outp(0x47e,i);
  102.  
  103. }
  104. *************************/
  105. void set_high(int sw,int sw2)
  106. {
  107.     int    i;
  108.     outpw(0x47a,0);
  109.     outp(0x47d,2);
  110.  
  111.     outpw(0x47a,0x2000);
  112.     outp(0x47c,1);
  113.     i = inp(0x47c) & 0x80;
  114.  
  115.     outp(0x47d,0x11);
  116.     outp(0x47f,9);
  117.  
  118.     outpw(0x47a,0x2010);
  119.     i = inp(0x47c) & 0x7f;
  120.     outp(0x47c,i);
  121.     outp(0x47c,0);
  122.     outp(0x47c,0x80);
  123.     outp(0x47f,0);
  124.  
  125.     /* 高解像度時の表示モード設定 */
  126.  
  127.     switch(sw){
  128.     case 0: /* 奇数/偶数両フィールド表示 */
  129.         i = 4;
  130.         break;
  131.     case 1: /* 奇数フィールド表示 */
  132.         i = 0;
  133.         break;
  134.     case 2: /* 偶数フィールド表示 */
  135.         i = 8;
  136.         break;
  137.     case 3: /* フレーム表示 */
  138.         i = 12;
  139.         break;
  140.     }
  141.     outp(0x47e,i);
  142.  
  143.  
  144.     outpw(0x47a,0x2011);
  145.     outp(0x47f,9);
  146.  
  147.     /* 高解像度時の表示サイズ */
  148.     switch(sw2){
  149.     case 0: /* 切り抜き表示(画面中央の512×384) */
  150.         outp(0x47c,0);
  151.         outp(0x47d,0);
  152.         break;
  153.     case 1: /* 縮小表示(512×384に間引き縮小) */
  154.         outp(0x47c,0xcd);
  155.         outp(0x47d,0xcd);
  156.         break;
  157.     case 2: /* 縮小表示(320×240に縮小) */
  158.         outp(0x47c,0);
  159.         outp(0x47d,0x80);
  160.         break;
  161.     }
  162.  
  163.  
  164.     outpw(0x47a,0x2020);
  165.     outpw(0x47c,0xfb4);
  166.  
  167.     outpw(0x47a,0x2022);
  168.     outpw(0x47c,0x137);
  169.  
  170.     outpw(0x47a,0x2023);
  171.     outpw(0x47c,0x7ff);
  172.  
  173.     outpw(0x47a,0x2024);
  174.     outpw(0x47c,0xfef);
  175.  
  176.     outpw(0x47a,0x2026);
  177.     outpw(0x47c,0x7ff);
  178.  
  179.     if (sw2==0) { /* 切り抜き表示(画面中央の512×384) */
  180.  
  181.         outpw(0x47a,0x2027);
  182.         outpw(0x47c,0x40);        /* x1 */
  183.  
  184.         outpw(0x47a,0x2028);
  185.         outpw(0x47c,0x23f);        /* x2 */
  186.  
  187.         outpw(0x47a,0x2029);
  188.         outpw(0x47c,0x18);        /* y1 */
  189.  
  190.         outpw(0x47a,0x202a);
  191.         outpw(0x47c,0xd7);        /* y2 */
  192.  
  193.     }else{
  194.         outpw(0x47a,0x2027);
  195.         outpw(0x47c,0);
  196.  
  197.         outpw(0x47a,0x2028);
  198.         outpw(0x47c,0x27f);
  199.     
  200.         outpw(0x47a,0x2029);
  201.         outpw(0x47c,0);
  202.  
  203.         outpw(0x47a,0x202a);
  204.         outpw(0x47c,0xef);
  205.     }
  206. /********
  207.     if (sw2==2) {
  208.  
  209.         outpw(0x47a,0x202b);
  210.         outpw(0x47c,0x60);
  211.  
  212.         outpw(0x47a,0x202c);
  213.         outpw(0x47c,0x48);
  214.  
  215.     }else{
  216. ********/
  217.  
  218.         outpw(0x47a,0x202b);
  219.         outpw(0x47c,0x60*2);
  220.  
  221.         outpw(0x47a,0x202c);
  222.         outpw(0x47c,0);
  223. /********
  224.     }
  225. ********/
  226.  
  227.     outpw(0x47a,0x202d);
  228.     outpw(0x47c,0x200);
  229.  
  230.     outpw(0x47a,0x2010);
  231.     i = inp(0x47e) | 1;
  232.     outp(0x47e,i);
  233.  
  234. }
  235.  
  236. int vc3_check()
  237. {
  238.     int    i;
  239.  
  240.     i = inp(0x479) & 0x40;
  241.     if (i!=0) return 1;
  242.  
  243.     outpw(0x47A,0x2000);
  244.     i = inp(0x47c) & 1;
  245.     if (i!=1) return 1;
  246.  
  247.     outpw(0x50a0,4);
  248.     i = inp(0x50a2) & 0x80;
  249.     if (i!=0) return 1;
  250.  
  251.     return 0;
  252. }
  253. int vbus_check()
  254. {
  255.     int    i;
  256.  
  257.     outpw(0x47A,0x2010);
  258.     i = inp(0x47E) & 1;
  259.     return i;
  260. }
  261.  
  262. void reset_vbus()
  263. {
  264.     int    i;
  265.  
  266.     outpw(0x47A,0x2010);
  267.     outp(0x47F,2);
  268.  
  269.     i=0;
  270.     while(i<1000000 && ((inp(0x47E) & 1) != 0)) i++;
  271.  
  272.     outp(0x47F,0);
  273.     outpw(0x47A,0x2000);
  274.     outp(0x47C,1);
  275. }
  276.  
  277. /**************
  278. void set_vbus()
  279. {
  280.     int    i;
  281.  
  282.     outpw(0x47A,0);
  283.     outp(0x47C,2);
  284.     outpw(0x47A,0x2000);
  285.     outp(0x47C,0x1);
  286.  
  287.     i=0;
  288.     while(i<1000000 && ((inp(0x47C) & 0x80) != 0)) i++;
  289.  
  290.     outp(0x47D,0x11);
  291.     outpw(0x47A,0x2010);
  292.     
  293.     i = inp(0x47C) & 0x7f;
  294.     outp(0x47C,i);
  295.     outp(0x47C,0);
  296.     outp(0x47C,0x80);
  297.     outp(0x47E,0);
  298.     outp(0x47F,0);
  299.  
  300.  
  301.     outpw(0x47A,0x2011);
  302.     outp(0x47F,9);
  303.     outp(0x47C,0);
  304.     outp(0x47D,0x80);
  305.  
  306.     outpw(0x47A,0x2020);
  307.     outpw(0x47C,0xfb4);
  308.  
  309.     outpw(0x47A,0x2022);
  310.     outpw(0x47C,0x137);
  311.  
  312.     outpw(0x47A,0x2023);
  313.     outpw(0x47C,0x7ff);
  314.  
  315.     outpw(0x47A,0x2024);
  316.     outpw(0x47C,0xfef);
  317.  
  318.     outpw(0x47A,0x2026);
  319.     outpw(0x47C,0x7ff);
  320.  
  321.     outpw(0x47A,0x2027);
  322.     outpw(0x47C,0x14);
  323.  
  324.     outpw(0x47A,0x2028);
  325.     outpw(0x47C,0x26b);
  326.  
  327.     outpw(0x47A,0x2029);
  328.     outpw(0x47C,0x8);
  329.  
  330.     outpw(0x47A,0x202A);
  331.     outpw(0x47C,0xE8);
  332.  
  333.     outpw(0x47A,0x202B);
  334.     outpw(0x47C,0x2);
  335.  
  336.     outpw(0x47A,0x202C);
  337.     outpw(0x47C,0x2);
  338.  
  339.     outpw(0x47A,0x202D);
  340.     outpw(0x47C,0x200);
  341.  
  342.     outpw(0x47A,0x2010);
  343.     i = inp(0x47E) | 1;
  344.     outpw(0x47E,i);
  345. }
  346. *****************/
  347. int    video_flg;
  348. void VC_on()
  349. {
  350.     if (vc3_check()) return;
  351.     if (vbus_check()) reset_vbus();
  352.  
  353.     EGB_writePage(work,1);
  354.     EGB_displayStart(work,0,512,32);
  355.     set_high(0,2);
  356.     EGB_writePage(work,0);
  357.     video_flg = 1;
  358. }
  359. void VC_off()
  360. {
  361.     if (vbus_check()) reset_vbus();
  362.     EGB_writePage(work,1);
  363.     EGB_color(work,1,0);
  364.     EGB_clearScreen(work);
  365.     EGB_writePage(work,0);
  366.     video_flg = 0;
  367. }
  368.  
  369.